#include<iostream>
#include<vector>
#include<string>
#include<stack>
using namespace std;
const int N = 2e5 + 10;
int st[N];
stack<int>stk;
string s;
int n;
int main()
{
	cin >> n;
	cin >> s;
	int idx = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '(') stk.push(i);
		else if (s[i] == ')') {
			if (stk.size()) {
				int k = stk.top();
				stk.pop();
				st[k] = 1, st[i] = -1;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (!idx && st[i] != 1)cout << s[i];
		idx += st[i];
	}
	return 0;
}